feat: add ComposerPackageConstraintInterface#7877
Open
calebdw wants to merge 1 commit intorectorphp:mainfrom
Open
feat: add ComposerPackageConstraintInterface#7877calebdw wants to merge 1 commit intorectorphp:mainfrom
calebdw wants to merge 1 commit intorectorphp:mainfrom
Conversation
This adds the ability to filter out rectors by composer package constraint.
747597b to
6bc2c5b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello!
This PR introduces a new
ComposerPackageConstraintInterfacethat allows individual Rector rules to specify a composer package constraint. Rules implementing this interface will be automatically skipped if the required package is not installed or does not satisfy the specified constraint.Motivation
This is analogous to
MinPhpVersionInterface(which skips rules based on PHP version) but for composer packages. This is particularly useful for framework-specific rules (e.g., Laravel, Symfony) where certain rules only make sense for specific package versions.Comparison with
ComposerTriggeredSetRector already has
ComposerTriggeredSetfor composer-based filtering, but it serves a different purpose:ComposerTriggeredSetComposerPackageConstraintInterface^) - targets specific major version>=,<,^,~, ranges, etc.)ComposerTriggeredSetis designed for upgrade paths where you want different sets for different version jumps (9→10, 10→11, etc.).ComposerPackageConstraintInterfaceis for rules that should only run when a package satisfies a specific constraint (for example, apply to a version and all subsequent version).Usage
Thanks!